package org.example.sentinel.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 季舟
 * @Date 2024-09-03 16:55
 */
@RestController
@RequestMapping("/demo")
public class DemoController {

    @SentinelResource(value = "getById", blockHandler = "blockHandler")
    @GetMapping("/{id}")
    Object getById(@PathVariable Integer id) {
        return id+"de";
    }

    public Object blockHandler(Integer id, BlockException e) {
        return "blockHandler";
    }

}